package com.dao;

import org.hibernate.Session;

import com.util.HbnUtil;

import entities.Product;

public class SearchProduct {

	public static Product searchByID(String productid){
		Session session=null;
		Product p=null;
		try{
		session=HbnUtil.getSession();
		session.beginTransaction();
		p=(Product)session.createQuery("from Product as u where u.productid='"+productid+"'").uniqueResult();
		if(p!=null)
			return p;
		session.beginTransaction().commit();
		}catch(Exception e){
			e.printStackTrace();
			session.beginTransaction().rollback();
		}finally{
			HbnUtil.releaseSession(session);
		}
		return null;
	}
}
